package stud.mpgame.server.game;

import stud.mpgame.network.UserObject;
import stud.mpgame.snapshot.ICommand;
import stud.mpgame.snapshot.ISnapshot;

import stud.mpgame.utils.ICloneable;

import java.util.List;

/**
 * @author f.pavel91@gmail.com
 * @version 1.0
 */
public class GameWorld extends UserObject implements ISnapshot, ICloneable {

    private int time;

    GameWorld(){}

    public GameWorld(int time) {
        this.time = time;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public ISnapshot modelNext(int deltaTime, List< ICommand > commands) {
		GameWorld gameWorld = (GameWorld) getClone();
		gameWorld.setTime(getTime() + deltaTime);
		for (ICommand command : commands) {
			command.apply(gameWorld);
        }
        //gameWorld.update(deltaTime);
		return gameWorld;
	}

	public ICloneable getClone() {
		GameWorld gameWorld = new GameWorld(time);
		return gameWorld;
	}

}
